<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../common.inc" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="./css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" language="javascript">
<!--
	function displayTable(obj){
		//alert(obj.value);
		if(obj.value == 1){
			document.getElementById("targetFrame").src = "monthTarget.html";
		}else if(obj.value == 2){
			document.getElementById("targetFrame").src = "seasonTarget.html";
		}else if(obj.value == 3){
			document.getElementById("targetFrame").src = "yearTarget.html";
		}else if(obj.value == 4){
			document.getElementById("targetFrame").src = "yearTarget.html";
		}else{
			document.getElementById("targetFrame").src = "emptyTarget.html";
		}
	}
	
	function getDeptId(){
		var objs = document.getElementsByName("deptId");
		var deptIds = "";
		for(var i = 0; i < objs.length; i++){
			if(objs[i].value != "")deptIds = deptIds + objs[i].value + ",";
		}
		return deptIds;
	}
	
	function deptDialog(){
		var url = "selectDept.html";
		var dlgParam = "dialogHeight:350px;dialogWidth:300px;dialogTop:300px;dialogLeft:400px;status:no;help:no;scrollbars:yes;";
		window.showModalDialog(url,"",dlgParam);
	}
	
	function updateTarget(){
		window.location.href = "./businessTarget.do?action=preUpdateTarget";
		window.location.target = "main";
	}
	
	function initPage(){
		if("<c:out value='${businessTarget.assignPeriod}'/>" == 1){
			document.getElementById("targetFrame").src = "./businessTarget.do?action=viewMonthTarget&deptIds="+getDeptId();
		}else if("<c:out value='${businessTarget.assignPeriod}'/>" == 2){
			document.getElementById("targetFrame").src = "./businessTarget.do?action=viewSeasonTarget&deptIds="+getDeptId();
		}else if("<c:out value='${businessTarget.assignPeriod}'/>" == 3){
			document.getElementById("targetFrame").src = "./businessTarget.do?action=viewYearTarget&deptIds="+getDeptId();
		}else{
			document.getElementById("targetFrame").src = "./businessTarget.do?action=emptyPage";
		}
	}
-->
</script>
</head>
<body onload="initPage()">
	<table class="table_frame" cellpadding="0" cellspacing="0">
		<tr>
			<td>
				<table class="table_title" cellpadding="0" cellspacing="0">
					<tr>
						<td class="title_lab" colspan="3">
							&nbsp;&nbsp;&nbsp;&nbsp;<fmt:message key='target.title.main'/>
						</td>
					</tr>
					<tr><td height="15"></td></tr>
					<tr>
						<td valign="bottom">&nbsp;
							<a href="javascript:updateTarget();" title="<fmt:message key='target.button.update'/>" hidefocus="true"><fmt:message key='target.button.update'/></a>
						</td>
						<td></td>
					</tr>
					<tr><td height="2"></td></tr>
				</table>
			</td>
		</tr>
		<tr>
			<td height="5"></td>
		</tr>
		<tr>
			<td>
				<table class="table2" cellpadding="0" cellspacing="0" >
					<tr>
						<td>
							<table class="table_lab" cellpadding="0" cellspacing="0">
								<tr>
									<td class="title">
										&nbsp;&nbsp;&nbsp;&nbsp;<fmt:message key='target.title.main'/>
									</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<td>
							<table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">
								<tr>
									<td valign="top">
										<!-- 
										<div style="width:800px;height:100%;overflow-x: scroll;overflow-y: hidden;">
										 -->
										<table class="table_style">
											<tr>
												<td class="title3" width="15%"><fmt:message key='target.lable.type'/><fmt:message key='common.sign'/></td>
												<td class="title3" width="40%">
													<fmt:message key="${businessTarget.assessmentTypeName}"/>
													<c:if test="${businessTarget.assessmentTypeValue != null}">${businessTarget.assessmentTypeValue}%</c:if>
													<c:if test="${businessTarget.assessmentTypeName2 != null}"><fmt:message key="${businessTarget.assessmentTypeName2}"/></c:if>
												</td>
												<td class="title3" width="15%"><fmt:message key='target.lable.assignDept'/><fmt:message key='common.sign'/></td>
												<td class="title3" width=""><%int i = 0; %>
													<c:forEach var="dept" items="${businessTarget.assignDepts}" varStatus="d">
														<c:if test="${dept.deptName != null && dept.deptName != ''}">
														${dept.deptName},<input id="deptId" name="deptId" type="hidden" value="${dept.id}"/>
														<%i = i + 1; %>
														<%if(i % 4 == 0){%><br><%}%>
														</c:if>
													</c:forEach>
												</td>
											</tr>
											<tr>
												<td class="title3" width="15%"><fmt:message key='target.title.main'/><fmt:message key='common.sign'/></td>
												<td class="title3">${businessTarget.totalTarget}<fmt:message key='common.lable.yuan'/></td>
												<td class="title3" width="15%"><fmt:message key='target.lable.assignPeriod'/><fmt:message key='common.sign'/></td>
												<td class="title3">
													<c:choose>
														<c:when test="${businessTarget.assignPeriod == '1'}"><fmt:message key='target.select.month'/></c:when>
														<c:when test="${businessTarget.assignPeriod == '2'}"><fmt:message key='target.select.season'/></c:when>
														<c:when test="${businessTarget.assignPeriod == '3'}"><fmt:message key='target.select.year'/></c:when>
														<c:otherwise>-</c:otherwise>
													</c:choose>
												</td>
											</tr>
										</table>
										<!-- 
										</div>
										 -->
									</td>
								</tr>
								<tr>
									<td valign="top">
										<iframe id="targetFrame" name="targetFrame" src="./businessTarget.do?action=emptyPage" frameborder="0" width="100%" 
											onload="this.height=targetFrame.document.body.scrollHeight;" scrolling="no"></iframe>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
</body>
</html>